home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / tex / rail.zip / GRAM.C < prev    next >
C/C++ Source or Header  |  1992-01-15  |  21KB  |  792 lines

  1. extern char *malloc(), *realloc();
  2.  
  3. # line 4 "gram.y"
  4.  
  5. #include <stdio.h>
  6.  
  7. #include "rail.h"
  8.  
  9. char optchar;
  10.  
  11. # define IDENTIFIER 257
  12. # define NUMBER 258
  13. # define ANNOT 259
  14. # define RAILI 260
  15. # define RAILP 261
  16. # define RAILT 262
  17. # define RAILCR 263
  18. # define CS 264
  19. # define STRING 265
  20. #define yyclearin yychar = -1
  21. #define yyerrok yyerrflag = 0
  22. extern int yychar;
  23. extern int yyerrflag;
  24. #ifndef YYMAXDEPTH
  25. #define YYMAXDEPTH 150
  26. #endif
  27. YYSTYPE yylval, yyval;
  28. # define YYERRCODE 256
  29.  
  30. # line 223 "gram.y"
  31.  
  32.  
  33. int yyexca[] ={
  34. -1, 1,
  35.     0, -1,
  36.     -2, 0,
  37. -1, 25,
  38.     125, 43,
  39.     59, 43,
  40.     124, 43,
  41.     -2, 0,
  42. -1, 43,
  43.     124, 43,
  44.     -2, 17,
  45.     };
  46. # define YYNPROD 46
  47. # define YYLAST 246
  48. int yyact[]={
  49.  
  50.     39,    44,    50,    51,    23,    39,    22,     6,    46,    16,
  51.     39,     3,     4,     5,    14,    39,    43,    64,    19,    39,
  52.     39,    17,    47,    25,    13,    11,     9,    53,    33,    37,
  53.     30,    27,    38,    60,    31,    36,    45,     2,    57,     7,
  54.     20,    18,    15,    12,    10,     8,     1,    34,    35,    26,
  55.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  56.      0,    48,     0,     0,     0,     0,     0,     0,     0,     0,
  57.     52,     0,     0,     0,    54,    56,    59,    55,     0,     0,
  58.     62,    62,    42,    61,    61,    63,    21,    66,    65,     0,
  59.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  60.     47,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  61.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  62.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  63.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  64.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  65.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  66.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  67.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  68.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  69.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  70.      0,     0,    46,     0,     0,     0,     0,     0,     0,     0,
  71.      0,     0,     0,     0,     0,     0,     0,    49,    24,     0,
  72.      0,    28,    29,    41,    32,    40,     0,    49,    41,    32,
  73.     40,     0,    49,    41,    58,    40,    49,    29,    41,    32,
  74.     40,     0,    41,    41,    40,    40 };
  75. int yypact[]={
  76.  
  77.   -249,  -249, -1000,   -97,   -98,   -99, -1000, -1000, -1000,  -244,
  78.  -1000, -1000, -1000,  -248,  -104, -1000,  -107, -1000,   -39, -1000,
  79.   -100, -1000, -1000, -1000, -1000,   -35,   -43, -1000, -1000,   -57,
  80.  -1000,  -102,   -21, -1000,   -40, -1000, -1000, -1000,   -36,   -30,
  81.   -251, -1000, -1000,   -20, -1000, -1000, -1000,   -25, -1000,  -251,
  82.    -21,   -21, -1000, -1000,   -24, -1000, -1000,   -30,   -21, -1000,
  83.  -1000, -1000, -1000, -1000, -1000, -1000, -1000 };
  84. int yypgo[]={
  85.  
  86.      0,    31,    49,    30,    34,    28,    48,    47,    35,    33,
  87.     32,    29,    36,    46,    37,    45,    44,    43,    42,    41,
  88.     40,    38 };
  89. int yyr1[]={
  90.  
  91.      0,    13,    13,    14,    14,    14,    14,    18,    16,    19,
  92.     19,    19,    19,    17,    20,    15,     2,     2,     2,     2,
  93.     21,     1,     1,     3,     4,     4,     4,     4,     5,     5,
  94.      5,     6,     6,     7,     7,     8,     8,     9,     9,    10,
  95.     10,    10,    10,    11,    12,    12 };
  96. int yyr2[]={
  97.  
  98.      0,     4,     2,     4,     4,     4,     2,     1,     9,     0,
  99.      5,     5,     5,     7,     1,    15,     7,     5,     2,     3,
  100.      1,     9,     3,     3,     9,     7,     5,     2,     7,     7,
  101.      2,     2,     2,     5,     2,     5,     2,     2,     2,     7,
  102.      5,     5,     3,     1,     3,     1 };
  103. int yychk[]={
  104.  
  105.  -1000,   -13,   -14,   260,   261,   262,   256,   -14,   -15,   123,
  106.    -16,   123,   -17,   123,   258,   -18,   257,   125,   -19,   125,
  107.    -20,   125,    45,    43,   257,   123,    -2,    -1,   256,   257,
  108.     -3,    -4,   259,    -5,    -7,    -6,    -8,   -11,   -10,    40,
  109.    265,   263,   125,    59,    58,   -12,   259,   124,    -5,   257,
  110.     42,    43,    -8,    63,    -4,   -12,    -1,   -21,   259,    -5,
  111.     -9,   -10,   -11,    -9,    41,    -3,    -5 };
  112. int yydef[]={
  113.  
  114.      0,    -2,     2,     0,     0,     0,     6,     1,     3,     0,
  115.      4,     7,     5,     0,     0,     9,     0,    14,     0,    13,
  116.      0,     8,    10,    11,    12,    -2,     0,    18,    19,    45,
  117.     22,    23,    43,    27,    31,    30,    34,    32,    36,    43,
  118.     45,    42,    15,    -2,    20,    41,    44,    43,    26,    45,
  119.     43,    43,    33,    35,     0,    40,    16,    43,    43,    25,
  120.     28,    37,    38,    29,    39,    21,    24 };
  121. typedef struct { char *t_name; int t_val; } yytoktype;
  122. #ifndef YYDEBUG
  123. #    define YYDEBUG    0    /* don't allow debugging */
  124. #endif
  125.  
  126. #if YYDEBUG
  127.  
  128. yytoktype yytoks[] =
  129. {
  130.     "IDENTIFIER",    257,
  131.     "NUMBER",    258,
  132.     "ANNOT",    259,
  133.     "RAILI",    260,
  134.     "RAILP",    261,
  135.     "RAILT",    262,
  136.     "RAILCR",    263,
  137.     "CS",    264,
  138.     "STRING",    265,
  139.     "-unknown-",    -1    /* ends search */
  140. };
  141.  
  142. char * yyreds[] =
  143. {
  144.     "-no such reduction-",
  145.     "rails : rails rail",
  146.     "rails : rail",
  147.     "rail : RAILI raili",
  148.     "rail : RAILP railp",
  149.     "rail : RAILT railt",
  150.     "rail : error",
  151.     "railp : '{'",
  152.     "railp : '{' options '}'",
  153.     "options : /* empty */",
  154.     "options : options '-'",
  155.     "options : options '+'",
  156.     "options : options IDENTIFIER",
  157.     "railt : '{' IDENTIFIER '}'",
  158.     "raili : '{' NUMBER '}'",
  159.     "raili : '{' NUMBER '}' '{' rules '}'",
  160.     "rules : rules ';' rule",
  161.     "rules : rules ';'",
  162.     "rules : rule",
  163.     "rules : error",
  164.     "rule : IDENTIFIER ':'",
  165.     "rule : IDENTIFIER ':' body",
  166.     "rule : body",
  167.     "body : body0",
  168.     "body0 : body0 '|' ANNOT body1",
  169.     "body0 : body0 '|' body1",
  170.     "body0 : ANNOT body1",
  171.     "body0 : body1",
  172.     "body1 : body2 '*' body4e",
  173.     "body1 : body2 '+' body4e",
  174.     "body1 : body2e",
  175.     "body2e : body2",
  176.     "body2e : empty",
  177.     "body2 : body2 body3",
  178.     "body2 : body3",
  179.     "body3 : body4 '?'",
  180.     "body3 : body4",
  181.     "body4e : body4",
  182.     "body4e : empty",
  183.     "body4 : '(' body0 ')'",
  184.     "body4 : STRING annot",
  185.     "body4 : IDENTIFIER annot",
  186.     "body4 : RAILCR",
  187.     "empty : /* empty */",
  188.     "annot : ANNOT",
  189.     "annot : /* empty */",
  190. };
  191. #endif /* YYDEBUG */
  192. #line 1 "/usr/lib/yaccpar"
  193. /*    @(#)yaccpar 1.10 89/04/04 SMI; from S5R3 1.10    */
  194.  
  195. /*
  196. ** Skeleton parser driver for yacc output
  197. */
  198.  
  199. /*
  200. ** yacc user known macros and defines
  201. */
  202. #define YYERROR        goto yyerrlab
  203. #define YYACCEPT    { free(yys); free(yyv); return(0); }
  204. #define YYABORT        { free(yys); free(yyv); return(1); }
  205. #define YYBACKUP( newtoken, newvalue )\
  206. {\
  207.     if ( yychar >= 0 || ( yyr2[ yytmp ] >> 1 ) != 1 )\
  208.     {\
  209.         yyerror( "syntax error - cannot backup" );\
  210.         goto yyerrlab;\
  211.     }\
  212.     yychar = newtoken;\
  213.     yystate = *yyps;\
  214.     yylval = newvalue;\
  215.     goto yynewstate;\
  216. }
  217. #define YYRECOVERING()    (!!yyerrflag)
  218. #ifndef YYDEBUG
  219. #    define YYDEBUG    1    /* make debugging available */
  220. #endif
  221.  
  222. /*
  223. ** user known globals
  224. */
  225. int yydebug;            /* set to 1 to get debugging */
  226.  
  227. /*
  228. ** driver internal defines
  229. */
  230. #define YYFLAG        (-1000)
  231.  
  232. /*
  233. ** static variables used by the parser
  234. */
  235. static YYSTYPE *yyv;            /* value stack */
  236. static int *yys;            /* state stack */
  237.  
  238. static YYSTYPE *yypv;            /* top of value stack */
  239. static int *yyps;            /* top of state stack */
  240.  
  241. static int yystate;            /* current state */
  242. static int yytmp;            /* extra var (lasts between blocks) */
  243.  
  244. int yynerrs;            /* number of errors */
  245.  
  246. int yyerrflag;            /* error recovery flag */
  247. int yychar;            /* current input token number */
  248.  
  249. /* register YYSTYPE *yypvt = 0;    /* top of value stack for $vars */
  250.  
  251. /*
  252. ** yyparse - return 0 if worked, 1 if syntax error not recovered from
  253. */
  254. int
  255. yyparse()
  256. {
  257.     register YYSTYPE *yypvt = 0;    /**/
  258.     unsigned yymaxdepth = YYMAXDEPTH;
  259.  
  260.     /*
  261.     ** Initialize externals - yyparse may be called more than once
  262.     */
  263.     yyv = (YYSTYPE*)malloc(yymaxdepth*sizeof(YYSTYPE));
  264.     yys = (int*)malloc(yymaxdepth*sizeof(int));
  265.     if (!yyv || !yys)
  266.     {
  267.         yyerror( "out